'use strict'

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    const { STRING, INTEGER, DATE, BOOLEAN } = Sequelize
    await queryInterface.createTable('admin_user', {
      id: {
        type: INTEGER(20).UNSIGNED,
        primaryKey: true,
        autoIncrement: true,
        comment: '主键id'
      },
      username: {
        type: STRING(50),
        allowNull: false,
        unique: true,
        comment: '用户名'
      },
      password: {
        type: STRING(255),
        allowNull: false,
        comment: '密码'
      },
      status: {
        type: BOOLEAN,
        allowNull: false,
        defaultValue: 1,
        comment: '状态 0:禁用 1:启用'
      },
      type: {
        type: BOOLEAN,
        allowNull: false,
        comment: '管理员类型 0 超级管理员 1 普通管理员',
        defaultValue: 0,
        values: [0, 1]
      },
      created_at: DATE,                   
      updated_at: DATE
    })
  },

  async down(queryInterface) {
    queryInterface.dropTable('admin_user')
  }
}
